package com.ruoyi.equipment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.equipment.domain.LgOrderLocation;
import com.ruoyi.equipment.domain.LgTemperature;
import com.ruoyi.equipment.domain.LgVehicle;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * @Author: lek
 * @Description: TODO
 * @Date: 2025/3/5 11:28
 * @Version: 1.0
 */
@Mapper
public interface LgTemperatureMapper extends BaseMapper<LgTemperature> {
    //查询搜索GPS设备信息
    public List<LgTemperature> selectLgTemperatureList(LgTemperature lgTemperature);
    //查询GPS设备信息
    public LgTemperature selectLgTemperatureById(Integer id);
    //查询车辆信息
    public LgVehicle selectVehicleById(Integer id);
    //修改车辆信息
    public int updateVehicle(LgVehicle lgVehicle);
    //查询车辆信息列表
    public List<LgVehicle> selectLgVehicleList(LgVehicle lgVehicle);

    public int insertOrderLocation();

    public LgTemperature selectTemperatureVehicleById(Integer id);

    public LgTemperature selectTemperatureVehicleBylicensePlate(String licensePlate);

    //根据订单编号差坐标
    @Select("SELECT a.order_number,a.device_number,a.current_temperature," +
            "a.current_humidity,a.latitude_x,a.latitude_y,a.current_status," +
            "a.bound_id,a.purchase_date,a.create_by,a.update_by,a.create_time,a.update_time" +
            " FROM lg_temperature a " +
            "LEFT JOIN lg_out_order b ON a.order_number = b.stock_order_number " +
            "WHERE b.stock_order_number = #{stockOrderNumber}")
    List<LgTemperature> getTemperatureByOrder(@Param("stockOrderNumber")Integer stockOrderNumber);
    @Select("SELECT d.latitude_x, d.latitude_y \n" +
            "FROM lg_temperature d \n" +
            "LEFT JOIN (\n" +
            "    SELECT a.vehicle_id \n" +
            "    FROM lg_delivery_info a \n" +
            "    LEFT JOIN lg_out_order b \n" +
            "    ON a.order_number = b.stock_order_number\n" +
            "\t\tWHERE b.stock_order_number = #{stockOrderNumber}\n" +
            ") c ON d.bound_id = c.vehicle_id WHERE d.bound_id=c.vehicle_id;")
    List<LgTemperature> getTemperatureByOrderGo(@Param("stockOrderNumber")Integer stockOrderNumber);

}
